package com.xh3140.android.widget.dialog.utils;

import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Px;
import androidx.annotation.Size;

public final class ViewUtils {
    /**
     * 禁止实例化
     */
    private ViewUtils() {
        throw new RuntimeException("This class prohibits instantiation.");
    }

    /**
     * 设置文本高度
     *
     * @param textView 文本显示控件
     * @param height   高度 px
     */
    public static void setTextViewHeight(@NonNull TextView textView, @Px int height) {
        if (height != 0) {
            textView.setHeight(height);
        }
    }

    /**
     * 设置视图内边距
     *
     * @param view    视图
     * @param padding 内边距 [start, top, end, bottom] px
     */
    public static void setPaddingRelative(@NonNull View view, @Nullable @Size(4) int[] padding) {
        if (padding != null) {
            view.setPaddingRelative(padding[0], padding[1], padding[2], padding[3]);
        }
    }
}
